/*
	SnowstormXEngineVars.h

	contains the definition for the snowstorm X engine vars

	Author: Aidan Goddard 7/8/14
*/

#ifndef SNOWSTORMXENGINEVARS_H_INCLUDED
#define SNOWSTORMXENGINEVARS_H_INCLUDED

#include<cstdint>
#include<Windows.h>

//////////////////////////////////////////////////
// Engine variables

struct XVARS
{
	// user input
	uint64_t KEYSTATE[4];
	int mickey_x;
	int mickey_y;
	int mickey_z;
	int screen_x;
	int screen_y;
	float xbox_rx;
	float xbox_ry;
	float xbox_lx;
	float xbox_ly;
	float xbox_rtr;
	float xbox_ltr;

	// frame vars
	double current_FPS;
	double frame_time; // gives the time the previous frame took to render in seconds

	// engine states
	int actions_paused;

};

#define PAUSE_STATE_NONE 0
#define PAUSE_STATE_MAP 1
#define PAUSE_STATE_ALL 2

#define v(x) ev->x
#define KEY_PRESSED(x) (ev->KEYSTATE[((x) / 64)] & (1ULL << ((x) % 64)))

typedef void(*EVENT)(XVARS *ev, uint32_t SNOWSTORM_ENGINE_TID);
#define EVENT(x) void((x))(XVARS *ev, uint32_t SNOWSTORM_ENGINE_TID)


// virual keys
// see http://msdn.microsoft.com/en-gb/library/windows/desktop/dd375731(v=vs.85).aspx (28/7/14) for
// MS virtual key listings
// additional virtual keys are defined below (for xbox 360 controller buttons and such) - all use virtual key values marked as "undefined" in the above MSDN page
#define VK_XBOXDPADUP		0x07
#define VK_XBOXDPADDOWN		0x0E
#define VK_XBOXDPADLEFT		0x0F
#define VK_XBOXDPADRIGHT	0x16
#define VK_XBOXA			0x1A
#define VK_XBOXB			0x3A
#define VK_XBOXX			0x3B
#define VK_XBOXY			0x3C
#define VK_XBOXLB			0x3D
#define VK_XBOXRB			0x3E
#define VK_XBOXSTART		0x3F
#define VK_XBOXBACK			0x40
#define VK_XBOXSELECT		0x40
#define VK_XBOXLT			0x88
#define VK_XBOXRT			0x89

// event types
#define EVENT_KEYPRESS		0x10000
#define EVENT_KEYHELD		0x20000
#define EVENT_KEYRELEASE	0x40000

#endif